package 原型模式.浅克隆;

/**
 * @author wzx
 * @date 2024/9/5 16:54
 * @description: 测试
 */
public class TestPrototype {

    public static void main(String[] args) throws CloneNotSupportedException {

        ConcretePrototype c1 = new ConcretePrototype();
        Person p1 = new Person("张三");
        c1.setPerson(p1);
        ConcretePrototype c2 = (ConcretePrototype) c1.clone();
        Person p2 = c2.getPerson();
        p2.setName("李四");
        System.out.println("对象c1和c2是同一个对象吗？："+(c1 == c2));
        c1.show();
        c2.show();
        System.out.println("对象c1和c2的person对象是同一个对象吗？："+(p1 == p2));
    }



}
